package com.tuojian.nanjing.healthysystem.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 指定扫描的 Controller 包
                .apis(RequestHandlerSelectors.basePackage("com.tuojian.nanjing.healthysystem.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("健康管理系统 API 文档")
                .description("提供体重记录、运动记录、每日打卡等功能接口")
                .version("1.0")
                .contact(new Contact("跑到手机关机", "https://example.com", "your@email.com"))
                .build();
    }
}
